﻿@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase

<div @attributes="@AdditionalAttributes" class="@PanelClassString">
    <div class="transfer-panel-header">
        @if(HeaderTemplate == null)
        {
            <Checkbox TValue="SelectedItem" DisplayText="@Text" IsDisabled="@IsDisabled" ShowAfterLabel="true" ShowLabel="false"
                      State="@HeaderCheckState()" OnStateChanged="@OnHeaderCheck" />
        }
        else
        {
            @HeaderTemplate(Items)
        }
    </div>
    <div class="transfer-panel-body">
        @if (ShowSearch)
        {
            <div class="transfer-panel-filter">
                <input type="text" autocomplete="off" placeholder="@SearchPlaceHolderString" disabled="@Disabled" class="input-inner" value="@SearchText" @oninput="@OnSearch" @onkeyup="@OnKeyUp">
                <span class="@SearchClass" @onclick="@ClearSearch">
                    <i class="@SearchIcon"></i>
                </span>
            </div>
        }
        <div role="group" aria-label="checkbox-group" class="@PanelListClassString">
            @foreach (var item in GetShownItems())
            {
                if(ItemTemplate == null)
                {
                    var state = item.Active ? CheckboxState.Checked : CheckboxState.UnChecked;
                    <Checkbox TValue="SelectedItem" IsDisabled="@IsDisabled" class="@GetItemClass(item)"
                                DisplayText="@item.Text" Value="item" ShowAfterLabel="true" ShowLabel="false"
                                State="@state" OnStateChanged="@OnStateChanged"></Checkbox>
                }
                else
                {
                    @ItemTemplate(item)
                }
            }
        </div>
    </div>
</div>
